from playwright.sync_api import Playwright, sync_playwright


import time


def run(playwright: Playwright)->None:
    browser=playwright.firefox.launch(headless=False)
    context=browser.new_context()
    page=browser.new_page()
    page.goto('https://www.baidu.com//')
    page.locator('#kw').fill("UI自动化测试")
    page.get_by_role("button",name="百度一下")
    time.sleep(10)

    context.close()
    browser.close()

with sync_playwright()as playwright:
    run(playwright)